Skip to content

[Refactor] Collapse sleep-check cancel-vs-fail finalization#69

Draft
roomote-roomote[bot] wants to merge 1 commit into
developfrom
refactor/sleep-check-finalize-swept-job-0d1wh7kjy2yjt
Draft

[Refactor] Collapse sleep-check cancel-vs-fail finalization#69
roomote-roomote[bot] wants to merge 1 commit into
developfrom
refactor/sleep-check-finalize-swept-job-0d1wh7kjy2yjt

Conversation

@roomote-roomote

Copy link
Copy Markdown
Contributor

Created by Roomote. Follow up by mentioning @roomote or in the web UI.

What changed

Sleep-check recovery paths that finalize a swept job as canceled or failed no longer each inline the same status resolution, event recording, logging, and finishCloudJob sequence. Those branches now call a shared finalizeSweptJob helper and only supply path-specific messages and details.

Why this change was made

After the canceled-task recovery work in #53, timed and heartbeat recovery paths still duplicated nearly identical cancel-vs-fail finalization blocks in an already large scheduled job. The next recovery path would have copied that third branch again.

Impact

No intentional user-facing behavior change. Canceled vs failed status selection, sleep-check events, and finish arguments stay the same; the scheduled job is easier to extend without another copy-paste when a new sweep recovery path is added.

Extract finalizeSweptJob so timed and heartbeat recovery paths share one
cancel-vs-fail finish/record/log path instead of copying branches.
@roomote-roomote

roomote-roomote Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

1 issue outstanding. See task

  • Medium: apps/bullmq/src/scheduled-jobs/sleep-check.ts:677-689 preserves a terminal sleep-check event and emits the success-style warning before finishCloudJob succeeds. For both heartbeat recovery branches this reverses the previous order, so a database/read or transaction failure in finishCloudJob can leave the run active while the durable audit trail already says it was failed or canceled; keep those outcome signals after successful finalization (or explicitly handle the failure case) before treating this as behavior-preserving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant